package com.zhang.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

import java.util.Arrays;

public class MyAspect {
    public void before(){
        System.out.println("before方法执行");
    }

    //前置通知
    public void a(){
        System.out.println("前置通知");
    }

    //后置通知
    public void b(){
        System.out.println("后置通知");
    }

    //环绕通知
    public Object c(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕通知");
        Object[] args = joinPoint.getArgs();
        Object proceed = joinPoint.proceed(args);
        System.out.println("环绕通知");
        return proceed;
    }

    //异常通知
    public void d(Exception e) {
        System.out.println("异常通知");
        System.out.println(e);
    }

    //返回通知
    public void e(JoinPoint joinPoint, Object result) throws Throwable {
        System.out.println("返回通知");
        System.out.println(Arrays.toString(joinPoint.getArgs()));
        System.out.println(result);
    }
}
